package com.dailyblue.project.estate.controller;

import com.dailyblue.project.estate.commons.bean.ChargeItem;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.service.ChargeItemService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:ChargeItemController
 * @Date:2025/9/18 14:13
 */
@RestController
@RequestMapping("/chargeItem")
public class ChargeItemController {
    @Resource
    private ChargeItemService chargeItemService;

    @PostMapping
    JsonResult saveChargeItem(ChargeItem chargeItem) {
        return chargeItemService.saveChargeItem(chargeItem);
    }

    @GetMapping("/{id}")
    JsonResult findOne(@PathVariable("id") String id) {
        return chargeItemService.findOne(id);
    }

    @GetMapping
    JsonResult findAll() {
        return chargeItemService.findAllChargeItems();
    }

    @DeleteMapping("/{id}")
    JsonResult deleteOne(@PathVariable("id") String id) {
        return chargeItemService.deleteChargeItem(id);
    }

    @PutMapping
    JsonResult updateOne(@RequestBody ChargeItem chargeItem) {
        return chargeItemService.updateChargeItem(chargeItem);
    }
}
